package top.roadvast.activiti;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;

import java.util.List;

/**
 * @Author 郭泽鹏
 * @Date 2020/6/24 19:54
 * @Description 查询流程定义信息
 * @Version 1.0
 */
public class ProcessDefinitionQuery {
    public static void main(String[] args) {
        ProcessEngine defaultProcessEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = defaultProcessEngine.getRepositoryService();

        org.activiti.engine.repository.ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();

        //设置条件
        List<ProcessDefinition> holiday = processDefinitionQuery.processDefinitionKey("holiday-uel")      //设置要查询的key
                .orderByProcessDefinitionVersion()                  //通过version进行进行降序排序
                .desc()
                .list();

        //输出流程定义信息
        for (ProcessDefinition processDefinition : holiday) {
            System.out.println("流程定义ID：" + processDefinition.getId());
            System.out.println("流程定义名称：" + processDefinition.getName());
            System.out.println("流程定义的key：" + processDefinition.getKey());
            System.out.println("流程定义的版本号：" + processDefinition.getVersion());
            System.out.println("流程定义部署的ID号：" + processDefinition.getDeploymentId());
        }
    }
}